package com.ukao.pad.adapter;

import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.pad.R;
import com.ukao.pad.bean.StationBean;
import com.ukao.pad.consts.SaveParamets;
import com.ukao.pad.eventbus.MainEvent;
import com.ukao.pad.utils.CheckUtils;

import java.util.List;

import static com.ukao.pad.eventbus.MainEvent.Message.station;

/**
 * Created by ukaodev on 2017/6/14.
 */

public class StationAdapter extends CommonAdapter<StationBean> {


    public StationAdapter(Context context, List<StationBean> datas ) {
        super(context, datas, R.layout.adapter_station);

    }


    @Override
    public void convert(ViewHolder holder, StationBean item) {

        TextView mshowText = holder.getView(R.id.showText);
        ImageView hook=holder.<ImageView>getView(R.id.hook);
        FrameLayout showTextLayout = holder.getView(R.id.showText_layout);
        mshowText.setText(item.getName());

        if (item.isCheck()){
            SaveParamets.setVal(item.getVal());
            SaveParamets.setValname(item.getName());
            MainEvent.postNoData(station);
            showTextLayout.setBackgroundResource(R.drawable.shape_factory_blue);
            mshowText.setTextColor(mContext.getResources().getColor(R.color.white));
            hook.setVisibility(View.VISIBLE);
        }else{
            hook.setVisibility(View.GONE);
            showTextLayout.setBackgroundResource(R.drawable.shape_factory_wite);
            mshowText.setTextColor(mContext.getResources().getColor(R.color.black));
        }
    }








}
